import pygame


class PlaneGame:
    def __init__(self):
        pygame.init()
        self.screen = pygame.display.set_mode((480, 700))
        pygame.display.set_caption('飞机大战')
        self.clock = pygame.time.Clock()
        self.is_loop = True
        self.bg = pygame.image.load('./images/background.png')
        self.bg_rect = self.bg.get_rect()
        self.plane = pygame.image.load('./images/me1.png')
        self.plane_rect = self.plane.get_rect()


    def start(self):
        while self.is_loop:
            self.__event_handler()
            self.screen.fill((0,0,0))
            self.screen.blit(self.bg, self.bg_rect)
            self.screen.blit(self.plane, self.plane_rect)
            pygame.draw.circle(self.screen, (255, 0,0), (240, 600), 20)
            self.clock.tick(40)
            pygame.display.update()
        pygame.quit()

    def __event_handler(self):
        for e in pygame.event.get():
            if e.type == pygame.QUIT:
                self.is_loop = False

pg = PlaneGame()
pg.start()

